package cn.sciento.farm.devicemanager.gateway.uplink.handler;

import cn.sciento.farm.devicemanager.gateway.uplink.service.SysMessageService;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.integration.mqtt.support.MqttHeaders;
import org.springframework.messaging.Message;
import org.springframework.messaging.MessageHandler;
import org.springframework.messaging.MessagingException;

public class SysMessageHandler implements MessageHandler {

    @Autowired
    private SysMessageService sysMessageService;

    @Override
    public void handleMessage(Message<?> message) throws MessagingException {
        sysMessageService.handle(message.getHeaders().get(MqttHeaders.RECEIVED_TOPIC).toString());
    }
}

